
导出dxf全名="D:\amtf\00南腾家居-项目\20220701 钱隆国际7-2406 青菜"
导出dxf全名 = 导出dxf全名.gsub!(/\\/, "/")

def draw(view)
  # Draw a square.
  points = [
    Geom::Point3d.new(0, 0, 0),
    Geom::Point3d.new(9, 0, 0),
    Geom::Point3d.new(9, 9, 0),
    Geom::Point3d.new(0, 9, 0)
  ]
  # Fill
  view.drawing_color = Sketchup::Color.new(255, 128, 128)
  view.draw(GL_QUADS, points)
  # Outline
  view.line_stipple = '' # Solid line
  view.drawing_color = Sketchup::Color.new(64, 0, 0)
  view.draw(GL_LINE_LOOP, points)
end
view = Sketchup.active_model.active_view
kk=view.average_refresh_time
view.average_refresh_time=10
draw(view)


refreshed_view = view.refresh

selection = Sketchup.active_model.selection
group1 = selection[0]
group1.material=nil
puts group1.material


selection = Sketchup.active_model.selection
group1 = selection[0]
puts group1.definition
group2 = selection[1]
puts group2.definition
puts group2.definition==group1.definition
number = group2.definition.count_instances
puts number


selection = Sketchup.active_model.selection
group1 = selection[0]
# group2 = group1.copy
# group2.name="kk"
selection.clear
model = Sketchup.active_model
entities = model.entities
group = entities.add_group(group1)
# group2 = group1.copy
group.name="kk"




model = Sketchup.active_model
selection = Sketchup.active_model.selection
e=selection[0]
puts e.curve
puts e.curve.typename
arccurve=e.curve
start_angle = arccurve.start_angle
end_angle = arccurve.end_angle
puts "start_angle"
puts start_angle.radians
puts end_angle.radians
if start_angle.radians==0.0 and end_angle.radians==360.0
  puts "是整圆"
end




# ees=e.definition.entities
ees=model.entities
puts "ees.count"
puts ees.count
曲线s = []

for e in ees do
  if e.is_a?( Sketchup::Edge )
    arccurve=e.curve
    if !曲线s.include?(arccurve)
      曲线s.push arccurve
    end
  end
end

puts "曲线s.count"
puts 曲线s.count
for e in 曲线s do
  # puts e.normal
  arccurve=e
  puts "arccurve"
  puts arccurve
  if arccurve==nil
    next
  end
  centerpoint = arccurve.center
  normal=arccurve.normal.normalize!
  puts normal
  radius = arccurve.radius
  puts radius
  xaxis = arccurve.xaxis
  puts "xaxis"
  puts xaxis.normalize!
  start_angle = arccurve.start_angle
  end_angle = arccurve.end_angle
  puts "start_angle"
  puts start_angle.radians
  puts end_angle.radians

  if normal[2]==-1
    puts "谁的法向反了？👇"
    puts radius

    vector = Geom::Vector3d.new 0,0,1
    normal2 = vector.normalize!
    start_angle2 =-end_angle
    end_angle2 =start_angle
    # start_angle =0.degrees
    # end_angle =30.degrees
    for ee in e.edges do
      ee.erase!
    end
    edges = ees.add_arc centerpoint, xaxis, normal2, radius, start_angle2, end_angle2
  end
end




first_edge = ees[0]
arccurve=first_edge.curve
puts arccurve.normal

# centerpoint = arccurve.center
centerpoint = Geom::Point3d.new(0,0,0)
# Create a circle perpendicular to the normal or Z axis
vector = Geom::Vector3d.new 0,0,1
normal = vector.normalize!
entities = model.active_entities
xaxis = arccurve.xaxis
radius = arccurve.radius
start_angle = arccurve.start_angle
end_angle = arccurve.end_angle
edges = ees.add_arc centerpoint, xaxis, normal, radius, start_angle, end_angle


normal_vector = Geom::Vector3d.new(0,0,1)
radius = 10

entities = Sketchup.active_model.entities
edgearray = entities.add_circle center_point, normal_vector, radius
first_edge = edgearray[0]
arccurve = first_edge.curve

first_edge.curve.normal=Geom::Vector3d.new(0,0,-1)

# for ee in ees do
#   # puts ee
#   puts ee.curve.normal
#   # if ee.is_a?( Sketchup::Edge )
#   #   puts "ee.material"
#   #   # puts e.material.name
#   #   puts ee.material
#   #   ee.material=nil
#   # end
# end

model = Sketchup.active_model
selection = Sketchup.active_model.selection
群组=selection[0]
  entities = 群组.entities
  材质=群组.material
  entities.each {|ee|
    if ee.is_a?( Sketchup::Face )
      材质=ee.material
      if 材质 !=nil
        材质名称=材质.name
        puts 材质名称
        break
      else
        材质名称=nil
      end
    end
  }



model = Sketchup.active_model
selection = Sketchup.active_model.selection
if selection.count == 0
  entities = model.active_entities
else
  entities=selection
end
for e in entities do
  if ( e.is_a?( Sketchup::ComponentInstance ) || e.is_a?( Sketchup::Group ))
    ees=e.definition.entities
    for ee in ees do
      if ee.is_a?( Sketchup::Edge )
        puts "ee.material"
        # puts e.material.name
        puts ee.material
        ee.material=nil
      end
      if ee.is_a?( Sketchup::Face )
        puts "ee.material"
        # puts e.material.name
        puts ee.material
        ee.material=nil
        ee.back_material=nil
      end
    end
  end
end






model = Sketchup.active_model
layers = model.layers
layer_by_name = layers["afu-门板"]
if layer_by_name != nil
  if !layer_by_name.visible?
    layer_by_name.visible=true
  end
end



selection = Sketchup.active_model.selection
拟导出对象 = selection[0]
entities=拟导出对象.definition.entities
entities.each {|e|
  if ( e.is_a?( Sketchup::ComponentInstance ) || e.is_a?( Sketchup::Group ))
    组件实例名=e.name
    if 组件实例名=="_ABF_Label"###把 _ABF_Label 的原点设置到 世界坐标系原点
      puts "找到定位用的标签了："+组件实例名
      tr = 拟导出对象.transformation*e.transformation
          标签xaxis=tr.xaxis
          # 相交轴 = 标签xaxis * X_AXIS
          相交轴 = Z_AXIS
          # x_anglex = X_AXIS.angle_between 标签xaxis
          # 原来你的夹角，是不会区分逆时针和顺时针的，不会有负值，也不会超过180°
          x_anglex = 标签xaxis.angle_between X_AXIS
          puts "x_anglex:"
          puts x_anglex
          puts x_anglex.radians
          标签平行x轴 = X_AXIS.parallel?(标签xaxis)
          puts "标签平行x轴:"
          puts 标签平行x轴
          旋转角度=-x_anglex
          # 旋转角度=-45.degrees
          # amtf.nil
          # if x_anglex.radians < 180
          # if x_anglex.radians < 90
          #   旋转角度=-x_anglex
          #   # 旋转角度=-(180-x_anglex.radians).degrees
          # end
          puts "旋转角度:"
          puts 旋转角度.radians
          rot = Geom::Transformation.rotation(tr.origin,相交轴,旋转角度)
          拟导出对象.transform! rot

          tr = 拟导出对象.transformation*e.transformation
          标签xaxis=tr.xaxis
          # x_anglex = X_AXIS.angle_between 标签xaxis
          x_anglex2 = 标签xaxis.angle_between X_AXIS
          puts "转动后x_anglex2:"
          puts x_anglex2
          puts x_anglex2.radians
          if x_anglex2!=0.0
            旋转角度=2*x_anglex
            puts "旋转角度:"
            puts 旋转角度.radians
            rot = Geom::Transformation.rotation(tr.origin,相交轴,旋转角度)
            拟导出对象.transform! rot
            tr = 拟导出对象.transformation*e.transformation

            标签xaxis=tr.xaxis
            x_anglex3 = 标签xaxis.angle_between X_AXIS
            puts "转动后x_anglex3:"
            puts x_anglex3
            puts x_anglex3.radians
            if x_anglex3!=0.0
              UI.messagebox "标签的x轴线没法转到和全局x轴平行，太难了，只能撂挑子了 ！"
              amtf.nil
            end
          end
      end
      break
  end
}


point2 = Geom::Point3d.new(160.737414, 31.856957, 1148.249988)
point1 = Geom::Point3d.new(0, 0, 0)
vector = point1.vector_to(point2)

selection = Sketchup.active_model.selection
c = selection[0]
entities=c.definition.entities
entities.each {|e|
  if ( e.is_a?( Sketchup::ComponentInstance ) || e.is_a?( Sketchup::Group ))
    组件实例名=e.name
    # puts 组件实例名
    if 组件实例名=="_ABF_Label"###把 _ABF_Label 的原点设置到 世界坐标系原点
      tr = e.transformation*c.transformation
      puts "tr.origin1:"
      puts tr.origin
      tr2 = e.transformation
      puts "tr2.origin:"
      puts tr2.origin
      vector = tr.origin.vector_to ORIGIN
      # point1 = Geom::Point3d.new(tr.origin.x*25.4, tr.origin.y*25.4, tr.origin.z*25.4)
      # point2 = Geom::Point3d.new(0, 0, 0)
      # vector = point1.vector_to(point2)
      puts "vector"
      puts vector

      # vector = ORIGIN.vector_to tr.origin
      # tr = Geom::Transformation.translation(vector)
      # c.transform! tr
      # puts "tr.origin1:"
      # puts tr.origin
      break
    end
  end
  }

selection = Sketchup.active_model.selection
c = selection[0]
entities=c.definition.entities
entities.each {|e|
  if ( e.is_a?( Sketchup::ComponentInstance ) || e.is_a?( Sketchup::Group ))
    组件实例名=e.name
    # puts 组件实例名
    if 组件实例名=="_ABF_Label"###把 _ABF_Label 的原点设置到 世界坐标系原点
      # tr = e.transformation*c.transformation
      tr = c.transformation*e.transformation
      puts "tr.origin1:"
      puts tr.origin

      tr2 = e.transformation
      puts "e.transformation.origin:"
      puts tr2.origin

      tr3 = c.transformation
      puts "c.transformation.origin:"
      puts tr3.origin

      vector = tr.origin.vector_to ORIGIN
      # vector = tr.origin
      # point1 = Geom::Point3d.new(tr.origin.x, tr.origin.y, 0)
      # vector = point1.vector_to(ORIGIN)
      puts vector
      tr = Geom::Transformation.translation(vector)
      c.transform! tr

      break
    end
  end
  }

selection = Sketchup.active_model.selection
c = selection[0]
point1 = Geom::Point3d.new(183/25.4, 0, 0)
point2 = Geom::Point3d.new(0, 0, 0)
vector = point1.vector_to(point2)
puts vector
tr = Geom::Transformation.translation(vector)
c.transform! tr


@selection = Sketchup.active_model.selection
boundingbox1=@selection[0].bounds
boundingbox2=@selection[1].bounds
boundingbox = boundingbox1.intersect(boundingbox2)
length = boundingbox.diagonal
width = boundingbox.width
puts "#{boundingbox.width}+#{boundingbox.height}+#{boundingbox.depth}"
干涉体积=boundingbox.width*boundingbox.height*boundingbox.depth
puts 干涉体积<0.1


selection = Sketchup.active_model.selection
group1 = selection[0]
group1 = group1.copy
group2 = selection[1]
group2 = group2.copy
result = group1.intersect(group2)
volume = result.volume
puts volume<0


def 遍历组件属性(e)
  if e.is_a? Sketchup::ComponentInstance or e.is_a? Sketchup::Group
    @model = Sketchup.active_model
    @entities = @model.active_entities
    @selection = @model.selection
    e=@selection[0]

    组件定义名=e.definition.name
    组件实例名=e.name
    e=e.definition
    dictionaries = e.attribute_dictionaries
    dictionaries.each { |dictionary|
      # puts dictionary.name
      # k='lenz'
      # v=dictionary[k]
      # puts "#{k} = #{v}"
      dictionary.each { | key, value |
        puts "#{key} = #{value}"
      }
      }
      puts 'kk:'
      puts e.get_attribute "dynamic_attributes", '_y_formula'
      puts 'kk:'
      puts e.get_attribute "dynamic_attributes", '_bh_formula'

      # http://cn.voidcc.com/question/p-ggqpvkrd-kh.html
      # 动态组件自定义属性名称前面加_，可以设置其公式
      e.set_attribute 'dynamic_attributes', '_bh_formula', 'box整柜!LenX-LenX'
  end
end

@model = Sketchup.active_model
selection = @model.selection
curve = selection[0].curve
puts curve.typename

组件定义名="智能"
关键词位置= 组件定义名=~ /铰链|智能|参数|侧封板/
关键词位置==nil

arr = [1, 2, 3]
arr.include?(1, 2)

arr = [1, 2, 3]
arr.delete(1)
arr

def test_callee
  caller_locations(1,1)[0].label
end
def test_method
  test_callee
end
puts test_method


└--▶左

# text = "rails 是 rails,  Ruby on Rails 非常好的 Ruby 框架Rails_排版yyy"
text = "rails 是 rails,  Ruby on Rails 非常好的 Ruby 框架Rails_sdfyyy"
text = "└--▶左rails 是 rails,  Ruby on Rails 非常好的 Ruby 框架Rails_sdfyyy"
text.gsub!(/_排版\S*/, "")
puts text

text = "└--▶左rails 是 rails,  Ruby on Rails 非常好的 Ruby 框架Rails_sdfyyy"
# text.gsub!(/[\f\n\r\t\v└--▶]/, "不认识！")
text.gsub!(/[\f\n\r\t\v]|└--▶/, "不认识！")
puts text


text = "└--▶左rails									是 rails,  Ruby on Rails 非常好的 Ruby 框架Rails_sdfyyy"
# text.gsub!(/[\f\n\r\t\v└--▶]/, "不认识！")
text.gsub!(/	/, "")
puts text


@model = Sketchup.active_model
selection = @model.selection
p selection[0]

entities = Sketchup.active_model.entities
entities.each {|e|
  p e.hidden?
}

@model = Sketchup.active_model
@entities = @model.active_entities
@selection = @model.selection
p @selection.contains?(entity)


@不含板字组件=[]
@含板字组件=[]
@板字上层组件=[]
entities = Sketchup.active_model.entities
entities.each {|e|
  递归识别组件(e)
}
@不含板字组件.each {|e|
  n=e.definition.name
  p n
  e.erase!
}



entities = kk.definition.entities
列出子件(entities)

e = Sketchup.active_model.entities[0]
e.is_a?( Sketchup::ComponentInstance ||Sketchup::ComponentInstance)

componentdefinition = Sketchup.active_model.definitions[0]
entities = componentdefinition.entities
entities.each {|e|
  p e
  # p e.name
}

model = Sketchup.active_model
definitions = model.definitions
kk=definitions['平板门#8'].name

@model = Sketchup.active_model
p  @model.definitions.length
@model.definitions.each {|e|
  p e
  p e.name
}

model = Sketchup.active_model
p model.layers.size
model.layers.purge_unused
p model.layers.size

model = Sketchup.active_model
层s=model.layers
层s.each {|e|
  p e
  if e.name=~ /五金/
    层s.remove(e,true)
  end
}


model = Sketchup.active_model
p  model.definitions.length
model.definitions.purge_unused
p  model.definitions.length

def self.erase_hidden( model, scope, each_options )
  entity_count = self.count_scope_entity( scope, model, each_options )
  progress = TT::Progressbar.new( entity_count, 'Erasing hidden entities' )
  e = nil # Init variables for speed
  count = self.each_entity_in_scope( scope, model, each_options ) { |e|
    progress.next
    erased = false
    if e.valid?
      if e.is_a?( Sketchup::Edge )
        # Edges needs to be checked further
        if e.hidden? || e.soft? || !e.layer.visible?
          unless self.edge_protected?( e )
            e.erase!
            erased = true
          end
        end
      elsif e.hidden? || !e.layer.visible?
        # Everything else is safe to erase.
        e.erase!
        erased = true
      end # if edge?
    end
    erased
  }
end

model = Sketchup.active_model
p  model.definitions.length
model.definitions.purge_unused
p  model.definitions.length
删除多余元素(model.entities)
for e in model.entities.to_a
  if !(e.is_a?( Sketchup::Face ) || e.is_a?( Sketchup::ComponentInstance ) || e.is_a?( Sketchup::Group )) then
    if e.is_a?( Sketchup::Edge )
      faces = e.faces
      p faces.size
      if faces.size<1
         e.erase!
      end
    else
      e.erase!
    end
  end
end
for d in model.definitions
  for e in d.entities.to_a
    if !(e.is_a?( Sketchup::Face ) || e.is_a?( Sketchup::ComponentInstance ) || e.is_a?( Sketchup::Group )) then
      if e.is_a?( Sketchup::Edge )
        faces = e.faces
        p faces.size
        if faces.size<1
           e.erase!
        end
      else
        e.erase!
      end
    end
  end
end

def 删除多余元素(entities)
  for e in entities.to_a
    if e.is_a?( Sketchup::ComponentInstance ) || e.is_a?( Sketchup::Group )
      删除多余元素(e.entities)
    elsif e.is_a?( Sketchup::Edge )
      faces = e.faces
      p faces.size
      if faces.size<1
          e.erase!
      end
    else !e.is_a?( Sketchup::Face )
      e.erase!
    end
  end
end

  @model = Sketchup.active_model
  c = 0
  for e in @model.entities.to_a
    p e
    c = c.next if yield( e )
  end
  for d in @model.definitions
    for e in d.entities.to_a
      p e
      c = c.next if yield( e )
    end
  end
  c
  p c
end


@model = Sketchup.active_model
file=@model.path
文件名 = File.basename(file, '.*')
路径 = File.dirname(file).freeze
全名=路径+'/'+文件名+'_排版'+'.skp'

    def self.create_cube
      @model = Sketchup.active_model
      @model.start_operation('Create Cube', true)
      group = @model.active_entities.add_group
      entities = group.entities
      points = [
        Geom::Point3d.new(0,   0,   0),
        Geom::Point3d.new(1.m, 0,   0),
        Geom::Point3d.new(1.m, 1.m, 0),
        Geom::Point3d.new(0,   1.m, 0)
      ]
      face = entities.add_face(points)
      face.pushpull(-1.m)
      @model.commit_operation
    end

@model = Sketchup.active_model
@entities = @model.active_entities
@entities.each{|e|
  p e.to_s
  # p e.definition.name.to_s
  # p e.parent.definition.name.to_s
  p e.parent.to_s
  p e.parent.name.to_s
  if e.parent.kind_of? Sketchup::@model
    p "编辑顶层"
  else
    p "编辑组件"
  end
}

@selection = @model.selection
@编辑中tr=@model.edit_transform
@原点 = Geom::Point3d.new(0,0,0)
@编辑中局部原点=@原点.transform(@编辑中tr)

@model = Sketchup.active_model
@编辑中组件tr=Sketchup.active_model.edit_transform
# entities = @model.active_entities
p "@编辑中组件tr="+@编辑中组件tr.to_a.to_s
p "kk:"+Geom::Point3d.new(0,0,0).transform(@编辑中组件tr).to_s
# tr=@编辑中组件tr.inverse
# p "@编辑中组件tr="+@编辑中组件tr.to_a.to_s
# p "tr="+tr.to_a.to_s


@model = Sketchup.active_model
@编辑中组件tr=Sketchup.active_model.edit_transform
kk=Geom::Point3d.new(0,0,0).transform(@编辑中组件tr)
p "kk:"+kk.to_s
tr=@编辑中组件tr.inverse
kkf=kk.transform(tr)
p "kkf:"+kkf.to_s

@model = Sketchup.active_model
@编辑中组件tr=Sketchup.active_model.edit_transform
kk=Geom::Point3d.new(1126.539699, -876.247148, 400).transform(@编辑中组件tr)
p "kk:"+kk.to_s





# p "kk:"+Geom::Point3d.new(1568.148555, -827.465945, 400).transform(tr).to_s

# # entities = @model.active_entities
# p "@编辑中组件tr="+@编辑中组件tr.to_a.to_s
# gtr = Geom::Transformation.new
# gtr = gtr / @编辑中组件tr
# p "gtr:"+gtr.to_a.to_s


@model = Sketchup.active_model
entities = @model.active_entities
line = entities.add_line  Geom::Point3d.new(0,0,0), Geom::Point3d.new(-974.501569, -117.074205, 98.970848)
line = entities.add_line  Geom::Point3d.new(0,0,0), Geom::Point3d.new(-1010.78431, -205.12424, 0)

@model = Sketchup.active_model
entities = @model.active_entities
line = entities.add_line  Geom::Point3d.new(0,0,0), Geom::Point3d.new(10,10,0)

@model = Sketchup.active_model
ent = @model.entities
line = ent.add_line  Geom::Point3d.new(0,0,0), Geom::Point3d.new(10,10,0)

@model = Sketchup.active_model
selection = @model.selection
gp = selection[0].definition.entities
gp = gp.add_line  Geom::Point3d.new(0,0,0), Geom::Point3d.new(10,10,0)

@model = Sketchup.active_model
selection = @model.selection
面 = selection[0]
面.vertices.each{|vt|
  vtp=vt.position
  p "vtp转换前："+vtp.to_s
  # vtp=vtp.transform( tr )
  # p "vtp转换后："+vtp.to_s
}



# 构造XYZ轴的6个方向的raytest列表,获取投影元素
  item_list = []
  [1, -1].each do |vec|
    (0..2).each do |i|
    cu_vec = Geom::Vector3d.new(0, 0, 0)
    cu_vec[i] = vec
    item_list << @model.raytest([偏移点, cu_vec], true)
  end
end
# 解析投影元素，存储内部空间的5个面
inner_faces = []
p "item_list.count="+item_list.count.to_s
item_list.each do |item|
  if item != nil
    # 过滤投影得到的面
    item_faces = item[1].select { |i| i.is_a? Sketchup::Face }
    # 去除没有投影面的
    inner_faces << item_faces[0] unless item_faces.empty?
  end
end
selection.add(inner_faces)



              if ar右 != nil
                击中点=ar右[0]
                @右面x=击中点[0]
                line = @entities.add_line @原点,Geom::Point3d.new(击中点)
              end
              if ar上 != nil
                击中点=ar上[0]
                @右面x=击中点[0]
                line = @entities.add_line @原点,Geom::Point3d.new(击中点)
              end
              if ar下 != nil
                击中点=ar下[0]
                @右面x=击中点[0]
                line = @entities.add_line @原点,Geom::Point3d.new(击中点)
              end



              # if 选择的面="内空左面" then
              #   # 识别击中ar(ar右)
              #   if ar右 != nil
              #     击中点=ar右[0]
              #     @右面x=击中点[0]
              #     # line = @entities.add_line @原点,Geom::Point3d.new(@右面x, @后面y, @下面z)
              #   end
              #   if ar前 != nil
              #     击中点=ar前[0]
              #     @前面y=击中点[1]
              #   end
              #   击中点=ar下[0]
              #   @下面z=击中点[2]
              #   击中点=ar上[0]
              #   @上面z=击中点[2]
              # end
              # @左下后点p=Geom::Point3d.new(@左面x, @后面y, @下面z)
              # @右下后点p=Geom::Point3d.new(@右面x, @后面y, @下面z)
              # @width = @左下后点p.distance @右下后点p

              # @左下前点p=Geom::Point3d.new(@左面x, @前面y, @下面z)
              # @depth = @左下后点p.distance @左下前点p

              # @左上后点p=Geom::Point3d.new(@左面x, @后面y, @上面z)
              # @height = @左下后点p.distance @左上后点p

              # # p "选择面法向.round="+选择面法向.to_s
              # @左下后点p=nil
              # 选择的面=""
              # case 选择面法向
              #   when Geom::Vector3d.new(1,0,0)
              #     选择的面="内空左面"
              #     p "选择了"+选择的面
              #     # @左下后点p=@ip.face.vt0p.transform( 选择点tr )
              #     # @ip.face.vertices.each{|vt|
              #     #   vtp=vt.position.transform( 选择点tr )
              #     #   y值=vtp[1]
              #     #   if y值<@左下后点p[1]
              #     #     @左下后点p[1]=y值
              #     #   end
              #     # }
              #     识别面对角点(@ip.face,选择点tr)
              #     @左面x=@最小x
              #     @前面y=@最大y
              #     @后面y=@最小y
              #     @上面z=@最大z
              #     @下面z=@最小z
              #     # p "@左面x……"
              #     # p @左面x
              #     # p @后面y
              #     # p @下面z
              #     # line = @entities.add_line @原点,Geom::Point3d.new(@左面x, @后面y, @下面z)
              #   when Geom::Vector3d.new(-1,0,0)
              #     选择的面="内空右面"
              #     识别面对角点(@ip.face,选择点tr)
              #     @右面x=@最小x
              #     @前面y=@最大y
              #     @后面y=@最小y
              #     @上面z=@最大z
              #     @下面z=@最小z
              # end

              kk=nil
              kk==nil ? kk="yy" : kk="jj"

                  # def 在单击点画矩形
    #   z1 = $ent.add_group
    #   fx1 = z1.@@entities.add_face [0,0,0],[50,0,0],[50,50,0],[0,50,0]
    #   fx1_f = fx1.pushpull -50
    #   $ent.transform_@@entities @ip,z1
    # end



  # cm1 = UI::Command.new("g"){
  # Sketchup.active_model.select_tool Tom1.new
  # }

  # toolbar = UI::Toolbar.new"t1z"
  # toolbar.add_item cm1
  # toolbar.show
